import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const index = () => import('../page/index')
const detail = () => import('../page/detail')
const getstart = () => import('../page/getstart')
const api = () => import('../page/api')
const about = () => import('../page/about')
const login = () => import('../page/login')
const signup = () => import('../page/signup')

import empty from '../page/404'

const router = new VueRouter({
	mode:'history',
	routes:[
		{path: '/',name:'index',component:index},
		{path: '/detail/:id',name:'detail',component:detail},
		{path: '/getstart',name:'getstart',component:getstart},
		{path: '/api',name:'api',component:api},
		{path: '/about',name:'about',component:about},
		{path: '/login',name:'login',component:login},
		{path: '/signup',name:'signup',component:signup},
		{path:'/*',name:'empty',component:empty}
	]
})

router.beforeEach(async (to, from, next) => {
	window.scrollTo(0, 0)
  next()
})
export default router